<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // var computer = {
        //     color: 'red',
        //     weight: '2KG',
        //     pinpai: 'apple',
        //     xinghao: '游戏本',
        //     fn: function () {
        //         console.log('打游戏')
        //     }
        // }
        // for (var k in computer) {
        //     console.log(k);  //k变量 输出得到的是属性名
        //     console.log(computer[k]);  //得到的是属性值
        // }
        function creatComputer(color, weight, pinpai, xinghao) {
            let obj = new Object();
            obj.color = color;
            obj.weight = weight;
            obj.pinpai = pinpai;
            obj.xinghao = xinghao;
            obj.playgame = function () {
                console.log('打游戏');
            }
            obj.seemovre = function () {
                console.log('看电影');
            }
            return obj;
        }
        let computer1 = creatComputer("red", "2KG", "华为", "游戏本");
        console.log(computer1);
        computer1.playgame();

    </script>
</head>

<body>

</body>

</html>